package com.wulian.common.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author FlowerMe on 2017-4-28.
 */
@ApiModel("返回结果Moudel")
public class  ResultMoudel<T> {

    public static final String SUCCESS_FLAG = "success";
    public static final String ERROR_FLAG = "error";

    @ApiModelProperty("成功标识：success:成功，error:失败")
    private String resultFlag;
    @ApiModelProperty("返回结果数据集")
    private T body;

    public ResultMoudel() {
    }

    public ResultMoudel(String resultFlag) {
        this.resultFlag = resultFlag;
    }

    public ResultMoudel(String resultFlag, T body) {
        this.resultFlag = resultFlag;
        this.body = body;
    }

    public ResultMoudel success(T body) {
        this.body = body;
        this.resultFlag = SUCCESS_FLAG;
        return  this;
    }
    public ResultMoudel error(T errorMessage) {
        this.resultFlag = ERROR_FLAG;
        this.body = errorMessage;
        return  this;
    }


    public String getResultFlag() {
        return resultFlag;
    }

    public void setResultFlag(String resultFlag) {
        this.resultFlag = resultFlag;
    }

    public T getBody() {
        return body;
    }

    public void setBody(T body) {
        this.body = body;
    }
}
